From 4c5ed7d2da9143cc64886ae3c1590bf85d80e937 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sat, 29 Dec 2007 03:29:37 +0000 Subject: [PATCH] Const'ified code with Babl*'s refering to formats. * babl/babl.h: * babl/babl-classes.h: * babl/babl-fish-path.c: * babl/babl-fish-reference.c: * babl/babl-fish.c: * babl/babl-internal.[ch]: Const'ified code with Babl*'s refering to formats. svn path=/trunk/; revision=260 --- ChangeLog | 10 ++++++++++ babl/babl-classes.h | 8 ++++---- babl/babl-fish-path.c | 26 +++++++++++++------------- babl/babl-fish-reference.c | 8 ++++---- babl/babl-fish.c | 20 ++++++++++---------- babl/babl-internal.c | 2 +- babl/babl-internal.h | 12 ++++++------ babl/babl.h | 6 +++--- 8 files changed, 51 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d4aaf0..b8c823e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-12-29 Øyvind Kolås + + * babl/babl.h: + * babl/babl-classes.h: + * babl/babl-fish-path.c: + * babl/babl-fish-reference.c: + * babl/babl-fish.c: + * babl/babl-internal.[ch]: Const'ified code with Babl*'s refering to + formats. + 2007-02-17 Øyvind Kolås * configure.ac: post release version increment to 0.0.17 diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 68c588a..52cb22f 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -91,8 +91,8 @@ typedef struct typedef struct BablConversion { BablInstance instance; - Babl *source; - Babl *destination; + const Babl *source; + const Babl *destination; long cost; double error; union @@ -197,8 +197,8 @@ typedef struct typedef struct { BablInstance instance; - Babl *source; - Babl *destination; + const Babl *source; + const Babl *destination; double error; /* the amount of noise introduced by the fish */ diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index 56b8e49..4fbb475 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -20,8 +20,8 @@ #include "babl-internal.h" static double -chain_error (Babl *fmt_source, - Babl *fmt_destination, +chain_error (const Babl *fmt_source, + const Babl *fmt_destination, BablConversion **chain, int conversions); @@ -66,8 +66,8 @@ static int max_path_length (void) typedef struct BablChainContext { - Babl *from; - Babl *to; + const Babl *from; + const Babl *to; double *best_cost; double *best_loss; @@ -87,8 +87,8 @@ chain_gen_each (Babl *babl, void *userdata); static int -get_conversion_chain (Babl *from, - Babl *to, +get_conversion_chain (const Babl *from, + const Babl *to, double *best_cost, double *best_loss, double *best_error, @@ -266,9 +266,9 @@ assert_conversion_find (void *source, static char buf[1024]; static char * -create_name (Babl *source, - Babl *destination, - int is_reference) +create_name (const Babl *source, + const Babl *destination, + int is_reference) { /* fish names are intentionally kept short */ snprintf (buf, 1024, "%s %p %p", "", @@ -277,8 +277,8 @@ create_name (Babl *source, } Babl * -babl_fish_path (Babl *source, - Babl *destination) +babl_fish_path (const Babl *source, + const Babl *destination) { Babl *babl = NULL; char *name = create_name (source, destination, 1); @@ -443,8 +443,8 @@ test_create (void) } static double -chain_error (Babl *fmt_source, - Babl *fmt_destination, +chain_error (const Babl *fmt_source, + const Babl *fmt_destination, BablConversion **chain, int conversions) { diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c index e80b091..073f7db 100644 --- a/babl/babl-fish-reference.c +++ b/babl/babl-fish-reference.c @@ -31,8 +31,8 @@ assert_conversion_find (void *source, static char buf[1024]; static char * -create_name (Babl *source, - Babl *destination, +create_name (const Babl *source, + const Babl *destination, int is_reference) { /* fish names are intentionally kept short */ @@ -45,8 +45,8 @@ create_name (Babl *source, Babl * -babl_fish_reference (Babl *source, - Babl *destination) +babl_fish_reference (const Babl *source, + const Babl *destination) { Babl *babl = NULL; char *name = create_name (source, destination, 1); diff --git a/babl/babl-fish.c b/babl/babl-fish.c index 3d14b05..7976912 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -36,13 +36,13 @@ match_conversion (Babl *conversion, } Babl * -babl_conversion_find (void *source, - void *destination) +babl_conversion_find (const void *source, + const void *destination) { - void *data = destination; + void *data = (void*)destination; babl_list_each ((void *) BABL (source)->type.from, match_conversion, &data); - if (data == destination) + if (data == (void*)destination) /* didn't change */ return NULL; return data; } @@ -56,8 +56,8 @@ babl_fish_db (void) } static inline Babl * -go_fishing (Babl *source, - Babl *destination) +go_fishing (const Babl *source, + const Babl *destination) { BablDb *db = babl_fish_db (); int i; @@ -78,12 +78,12 @@ go_fishing (Babl *source, } Babl * -babl_fish (void *source, - void *destination, +babl_fish (const void *source, + const void *destination, ...) { - Babl *source_format = NULL; - Babl *destination_format = NULL; + const Babl *source_format = NULL; + const Babl *destination_format = NULL; babl_assert (source); babl_assert (destination); diff --git a/babl/babl-internal.c b/babl/babl-internal.c index 785821f..8de4ce5 100644 --- a/babl/babl-internal.c +++ b/babl/babl-internal.c @@ -132,7 +132,7 @@ babl_internal_destroy (void) const char * -babl_name (Babl *babl) +babl_name (const Babl *babl) { babl_assert (BABL_IS_BABL (babl)); return babl->instance.name; diff --git a/babl/babl-internal.h b/babl/babl-internal.h index e1b4cc4..9afac6f 100644 --- a/babl/babl-internal.h +++ b/babl/babl-internal.h @@ -49,8 +49,8 @@ #define random rand #endif -Babl * babl_conversion_find (void *source, - void *destination); +Babl * babl_conversion_find (const void *source, + const void *destination); double babl_conversion_error (BablConversion *conversion); long babl_conversion_cost (BablConversion *conversion); long babl_conversion_process (Babl *conversion, @@ -75,12 +75,12 @@ long babl_fish_reference_process (Babl *babl, long n); BablDb * babl_fish_db (void); -Babl * babl_fish_reference (Babl *source, - Babl *destination); +Babl * babl_fish_reference (const Babl *source, + const Babl *destination); Babl * babl_fish_simple (BablConversion *conversion); void babl_fish_stats (FILE *file); -Babl * babl_fish_path (Babl *source, - Babl *destination); +Babl * babl_fish_path (const Babl *source, + const Babl *destination); long babl_fish_path_process (Babl *babl, void *source, diff --git a/babl/babl.h b/babl/babl.h index 3553ae7..739c277 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -72,8 +72,8 @@ typedef int (*BablEachFunction) (Babl *entry, * destination_format, source and destination can be * either strings with the names of the formats or BablFormat objects. */ -Babl * babl_fish (void *source_format, - void *destination_format, +Babl * babl_fish (const void *source_format, + const void *destination_format, ...); /** Process n pixels from source to destination using babl_fish, @@ -189,7 +189,7 @@ Babl * babl_sampling (int horizontal, */ -const char *babl_name (Babl *babl); /* returns the name of a babl object */ +const char *babl_name (const Babl *babl); /* returns the name of a babl object */ void babl_introspect (Babl *babl); /* introspect a given BablObject */ #undef BABL_CLASS -- 2.30.2